package com.bom_samaritano.dao;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class DBHelper extends SQLiteOpenHelper {

	private static final String DATABASE_NAME = "samaritano.db";
	private static final int DATABASE_VERSION = 1;

	DBHelper(Context context) {
		super(context, DATABASE_NAME, null, DATABASE_VERSION);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {

		db.execSQL("CREATE TABLE IF NOT EXISTS "
				+ Person.TABLE
				+ " ( id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, name VARCHAR NULL, email VARCHAR NULL, phone VARCHAR NULL, "
				+ "vacancy INTEGER UNSIGNED NULL, hascar BIT NULL, PRIMARY KEY(id) );");

		db.execSQL("CREATE TABLE IF NOT EXISTS "
				+ Route.TABLE
				+ " (id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, person_id INTEGER UNSIGNED NOT NULL, lat_origin DOUBLE NULL, lon_origin DOUBLE NULL,"
				+ "lat_destination DOUBLE NULL, lon_destination DOUBLE NULL, PRIMARY KEY(id), INDEX route_FKIndex1(person_id) );");
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		throw new UnsupportedOperationException();
	}
}